package com.ganbo.pattern.prototype;

import lombok.AllArgsConstructor;
import lombok.Data;

import java.io.Serializable;

/**
 * @Author: ganbo
 * @Date: 2020/6/9 10:33
 */

@Data
@AllArgsConstructor
public class User implements Serializable {
    private static final long serialVersionUID = 2631590509760908281L;

    private Long id;
    private String name;
    private Address address;


    public static void main(String[] args) throws Exception {
        Address address = new Address(1L, "成都市高新区");

        User user = new User(1L, "admin", address);
        User userClone = CloneUtil.clone(user);
        userClone.getAddress().setName("四川省成都市.");

        System.out.println(user);
        System.out.println(userClone);
    }
}

@Data
@AllArgsConstructor
class Address implements Serializable {
    private Long id;
    private String name;

}
